package cn.zy._05tx;

import org.apache.rocketmq.client.producer.LocalTransactionState;
import org.apache.rocketmq.client.producer.TransactionListener;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.common.message.MessageExt;

public class MyTransactionCheckListener implements TransactionListener {
    @Override
    public LocalTransactionState executeLocalTransaction(Message message, Object o) {
        //提交本地事务，并响应给mq提交成功的信息
        System.out.println("执行本地事务");
        System.out.println("接收参数为：" + o);
        return LocalTransactionState.COMMIT_MESSAGE;
    }

    @Override
    public LocalTransactionState checkLocalTransaction(MessageExt messageExt) {
        //mq去查本地事务，这里响应本地事务提交成功的信息
        System.out.println("会查本地事务");
        return LocalTransactionState.COMMIT_MESSAGE;
    }
}